Search in sources :

Example 1 with ProducerMetrics

use of org.apache.kafka.clients.producer.internals.ProducerMetrics in project kafka by apache.

the class KafkaProducer method newSender.

// visible for testing
Sender newSender(LogContext logContext, KafkaClient kafkaClient, ProducerMetadata metadata) {
    int maxInflightRequests = producerConfig.getInt(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION);
    int requestTimeoutMs = producerConfig.getInt(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG);
    ChannelBuilder channelBuilder = ClientUtils.createChannelBuilder(producerConfig, time, logContext);
    ProducerMetrics metricsRegistry = new ProducerMetrics(this.metrics);
    Sensor throttleTimeSensor = Sender.throttleTimeSensor(metricsRegistry.senderMetrics);
    KafkaClient client = kafkaClient != null ? kafkaClient : new NetworkClient(new Selector(producerConfig.getLong(ProducerConfig.CONNECTIONS_MAX_IDLE_MS_CONFIG), this.metrics, time, "producer", channelBuilder, logContext), metadata, clientId, maxInflightRequests, producerConfig.getLong(ProducerConfig.RECONNECT_BACKOFF_MS_CONFIG), producerConfig.getLong(ProducerConfig.RECONNECT_BACKOFF_MAX_MS_CONFIG), producerConfig.getInt(ProducerConfig.SEND_BUFFER_CONFIG), producerConfig.getInt(ProducerConfig.RECEIVE_BUFFER_CONFIG), requestTimeoutMs, producerConfig.getLong(ProducerConfig.SOCKET_CONNECTION_SETUP_TIMEOUT_MS_CONFIG), producerConfig.getLong(ProducerConfig.SOCKET_CONNECTION_SETUP_TIMEOUT_MAX_MS_CONFIG), time, true, apiVersions, throttleTimeSensor, logContext);
    short acks = Short.parseShort(producerConfig.getString(ProducerConfig.ACKS_CONFIG));
    return new Sender(logContext, client, metadata, this.accumulator, maxInflightRequests == 1, producerConfig.getInt(ProducerConfig.MAX_REQUEST_SIZE_CONFIG), acks, producerConfig.getInt(ProducerConfig.RETRIES_CONFIG), metricsRegistry.senderMetrics, time, requestTimeoutMs, producerConfig.getLong(ProducerConfig.RETRY_BACKOFF_MS_CONFIG), this.transactionManager, apiVersions);
}
Also used : Sender(org.apache.kafka.clients.producer.internals.Sender) NetworkClient(org.apache.kafka.clients.NetworkClient) KafkaClient(org.apache.kafka.clients.KafkaClient) ChannelBuilder(org.apache.kafka.common.network.ChannelBuilder) KafkaProducerMetrics(org.apache.kafka.clients.producer.internals.KafkaProducerMetrics) ProducerMetrics(org.apache.kafka.clients.producer.internals.ProducerMetrics) Sensor(org.apache.kafka.common.metrics.Sensor) Selector(org.apache.kafka.common.network.Selector)

Aggregations

KafkaClient (org.apache.kafka.clients.KafkaClient)1 NetworkClient (org.apache.kafka.clients.NetworkClient)1 KafkaProducerMetrics (org.apache.kafka.clients.producer.internals.KafkaProducerMetrics)1 ProducerMetrics (org.apache.kafka.clients.producer.internals.ProducerMetrics)1 Sender (org.apache.kafka.clients.producer.internals.Sender)1 Sensor (org.apache.kafka.common.metrics.Sensor)1 ChannelBuilder (org.apache.kafka.common.network.ChannelBuilder)1 Selector (org.apache.kafka.common.network.Selector)1