Package org.apache.kafka.clients.producer.internals

Examples of org.apache.kafka.clients.producer.internals.Sender$SenderMetrics


                                                 clientId,
                                                 config.getInt(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION),
                                                 config.getLong(ProducerConfig.RECONNECT_BACKOFF_MS_CONFIG),
                                                 config.getInt(ProducerConfig.SEND_BUFFER_CONFIG),
                                                 config.getInt(ProducerConfig.RECEIVE_BUFFER_CONFIG));
        this.sender = new Sender(client,
                                 this.metadata,
                                 this.accumulator,
                                 config.getInt(ProducerConfig.MAX_REQUEST_SIZE_CONFIG),
                                 (short) parseAcks(config.getString(ProducerConfig.ACKS_CONFIG)),
                                 config.getInt(ProducerConfig.RETRIES_CONFIG),
View Full Code Here


    @Test
    public void testRetries() throws Exception {
        // create a sender with retries = 1
        int maxRetries = 1;
        Sender sender = new Sender(client,
                                   metadata,
                                   this.accumulator,
                                   MAX_REQUEST_SIZE,
                                   ACKS_ALL,
                                   maxRetries,
                                   REQUEST_TIMEOUT_MS,
                                   new Metrics(),
                                   time);
        // do a successful retry
        Future<RecordMetadata> future = accumulator.append(tp, "key".getBytes(), "value".getBytes(), CompressionType.NONE, null).future;
        sender.run(time.milliseconds()); // connect
        sender.run(time.milliseconds()); // send produce request
        assertEquals(1, client.inFlightRequestCount());
        client.disconnect(client.requests().peek().request().destination());
        assertEquals(0, client.inFlightRequestCount());
        sender.run(time.milliseconds()); // receive error
        sender.run(time.milliseconds()); // reconnect
        sender.run(time.milliseconds()); // resend
        assertEquals(1, client.inFlightRequestCount());
        int offset = 0;
        client.respond(produceResponse(tp.topic(), tp.partition(), offset, Errors.NONE.code()));
        sender.run(time.milliseconds());
        assertTrue("Request should have retried and completed", future.isDone());
        assertEquals(offset, future.get().offset());

        // do an unsuccessful retry
        future = accumulator.append(tp, "key".getBytes(), "value".getBytes(), CompressionType.NONE, null).future;
        sender.run(time.milliseconds()); // send produce request
        for (int i = 0; i < maxRetries + 1; i++) {
            client.disconnect(client.requests().peek().request().destination());
            sender.run(time.milliseconds()); // receive error
            sender.run(time.milliseconds()); // reconnect
            sender.run(time.milliseconds()); // resend
        }
        sender.run(time.milliseconds());
        completedWithError(future, Errors.NETWORK_EXCEPTION);
    }
View Full Code Here

TOP

Related Classes of org.apache.kafka.clients.producer.internals.Sender$SenderMetrics

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.