@ -104,7 +104,7 @@ public class SenderTest {
@@ -104,7 +104,7 @@ public class SenderTest {
private RecordAccumulator accumulator = null ;
private Sender sender = null ;
private SenderMetricsRegistry senderMetricsRegistry = null ;
private final LogContext loggerFactory = new LogContext ( ) ;
private final LogContext logContext = new LogContext ( ) ;
@Before
public void setup ( ) {
@ -240,7 +240,7 @@ public class SenderTest {
@@ -240,7 +240,7 @@ public class SenderTest {
Node node = cluster . nodes ( ) . get ( 0 ) ;
NetworkClient client = new NetworkClient ( selector , metadata , "mock" , Integer . MAX_VALUE ,
1000 , 1000 , 64 * 1024 , 64 * 1024 , 1000 ,
time , true , new ApiVersions ( ) , throttleTimeSensor , new LogContext ( ) ) ;
time , true , new ApiVersions ( ) , throttleTimeSensor , logContext ) ;
short apiVersionsResponseVersion = ApiKeys . API_VERSIONS . latestVersion ( ) ;
ByteBuffer buffer = ApiVersionsResponse . createApiVersionsResponse ( 400 , RecordBatch . CURRENT_MAGIC_VALUE ) . serialize ( apiVersionsResponseVersion , new ResponseHeader ( 0 ) ) ;
@ -277,7 +277,7 @@ public class SenderTest {
@@ -277,7 +277,7 @@ public class SenderTest {
int maxRetries = 1 ;
Metrics m = new Metrics ( ) ;
try {
Sender sender = new Sender ( loggerFactory , client , metadata , this . accumulator , false , MAX_REQUEST_SIZE , ACKS_ALL ,
Sender sender = new Sender ( logContext , client , metadata , this . accumulator , false , MAX_REQUEST_SIZE , ACKS_ALL ,
maxRetries , m , new SenderMetricsRegistry ( ) , time , REQUEST_TIMEOUT , 50 , null , apiVersions ) ;
// do a successful retry
Future < RecordMetadata > future = accumulator . append ( tp0 , 0L , "key" . getBytes ( ) , "value" . getBytes ( ) , null , null , MAX_BLOCK_TIMEOUT ) . future ;
@ -324,7 +324,7 @@ public class SenderTest {
@@ -324,7 +324,7 @@ public class SenderTest {
int maxRetries = 1 ;
Metrics m = new Metrics ( ) ;
try {
Sender sender = new Sender ( loggerFactory , client , metadata , this . accumulator , true , MAX_REQUEST_SIZE , ACKS_ALL , maxRetries ,
Sender sender = new Sender ( logContext , client , metadata , this . accumulator , true , MAX_REQUEST_SIZE , ACKS_ALL , maxRetries ,
m , new SenderMetricsRegistry ( ) , time , REQUEST_TIMEOUT , 50 , null , apiVersions ) ;
// Create a two broker cluster, with partition 0 on broker 0 and partition 1 on broker 1
Cluster cluster1 = TestUtils . clusterWith ( 2 , "test" , 2 ) ;
@ -576,7 +576,7 @@ public class SenderTest {
@@ -576,7 +576,7 @@ public class SenderTest {
int maxRetries = 10 ;
Metrics m = new Metrics ( ) ;
Sender sender = new Sender ( loggerFactory , client , metadata , this . accumulator , true , MAX_REQUEST_SIZE , ACKS_ALL , maxRetries ,
Sender sender = new Sender ( logContext , client , metadata , this . accumulator , true , MAX_REQUEST_SIZE , ACKS_ALL , maxRetries ,
m , new SenderMetricsRegistry ( ) , time , REQUEST_TIMEOUT , 50 , transactionManager , apiVersions ) ;
Future < RecordMetadata > responseFuture = accumulator . append ( tp0 , time . milliseconds ( ) , "key" . getBytes ( ) , "value" . getBytes ( ) , null , null , MAX_BLOCK_TIMEOUT ) . future ;
@ -618,7 +618,7 @@ public class SenderTest {
@@ -618,7 +618,7 @@ public class SenderTest {
int maxRetries = 10 ;
Metrics m = new Metrics ( ) ;
SenderMetricsRegistry metricsRegistry = new SenderMetricsRegistry ( ) ;
Sender sender = new Sender ( loggerFactory , client , metadata , this . accumulator , true , MAX_REQUEST_SIZE , ACKS_ALL , maxRetries ,
Sender sender = new Sender ( logContext , client , metadata , this . accumulator , true , MAX_REQUEST_SIZE , ACKS_ALL , maxRetries ,
m , metricsRegistry , time , REQUEST_TIMEOUT , 50 , transactionManager , apiVersions ) ;
Future < RecordMetadata > responseFuture = accumulator . append ( tp0 , time . milliseconds ( ) , "key" . getBytes ( ) , "value" . getBytes ( ) , null , null , MAX_BLOCK_TIMEOUT ) . future ;
@ -655,7 +655,7 @@ public class SenderTest {
@@ -655,7 +655,7 @@ public class SenderTest {
int maxRetries = 10 ;
Metrics m = new Metrics ( ) ;
Sender sender = new Sender ( loggerFactory , client , metadata , this . accumulator , true , MAX_REQUEST_SIZE , ACKS_ALL , maxRetries ,
Sender sender = new Sender ( logContext , client , metadata , this . accumulator , true , MAX_REQUEST_SIZE , ACKS_ALL , maxRetries ,
m , new SenderMetricsRegistry ( ) , time , REQUEST_TIMEOUT , 50 , transactionManager , apiVersions ) ;
Future < RecordMetadata > responseFuture = accumulator . append ( tp0 , time . milliseconds ( ) , "key" . getBytes ( ) , "value" . getBytes ( ) , null , null , MAX_BLOCK_TIMEOUT ) . future ;
@ -684,7 +684,7 @@ public class SenderTest {
@@ -684,7 +684,7 @@ public class SenderTest {
public void testTransactionalSplitBatchAndSend ( ) throws Exception {
ProducerIdAndEpoch producerIdAndEpoch = new ProducerIdAndEpoch ( 123456L , ( short ) 0 ) ;
TopicPartition tp = new TopicPartition ( "testSplitBatchAndSend" , 1 ) ;
TransactionManager txnManager = new TransactionManager ( "testSplitBatchAndSend" , 60000 , 100 ) ;
TransactionManager txnManager = new TransactionManager ( logContext , "testSplitBatchAndSend" , 60000 , 100 ) ;
setupWithTransactionState ( txnManager ) ;
doInitTransactions ( txnManager , producerIdAndEpoch ) ;
@ -705,10 +705,10 @@ public class SenderTest {
@@ -705,10 +705,10 @@ public class SenderTest {
// Set a good compression ratio.
CompressionRatioEstimator . setEstimation ( topic , CompressionType . GZIP , 0 . 2f ) ;
try ( Metrics m = new Metrics ( ) ) {
accumulator = new RecordAccumulator ( loggerFactory , batchSize , 1024 * 1024 , CompressionType . GZIP , 0L , 0L , m , time ,
accumulator = new RecordAccumulator ( logContext , batchSize , 1024 * 1024 , CompressionType . GZIP , 0L , 0L , m , time ,
new ApiVersions ( ) , txnManager ) ;
SenderMetricsRegistry metricsRegistry = new SenderMetricsRegistry ( ) ;
Sender sender = new Sender ( loggerFactory , client , metadata , this . accumulator , true , MAX_REQUEST_SIZE , ACKS_ALL , maxRetries ,
Sender sender = new Sender ( logContext , client , metadata , this . accumulator , true , MAX_REQUEST_SIZE , ACKS_ALL , maxRetries ,
m , metricsRegistry , time , REQUEST_TIMEOUT , 1000L , txnManager , new ApiVersions ( ) ) ;
// Create a two broker cluster, with partition 0 on broker 0 and partition 1 on broker 1
Cluster cluster1 = TestUtils . clusterWith ( 2 , topic , 2 ) ;
@ -826,10 +826,10 @@ public class SenderTest {
@@ -826,10 +826,10 @@ public class SenderTest {
metricTags . put ( "client-id" , CLIENT_ID ) ;
MetricConfig metricConfig = new MetricConfig ( ) . tags ( metricTags ) ;
this . metrics = new Metrics ( metricConfig , time ) ;
this . accumulator = new RecordAccumulator ( loggerFactory , batchSize , 1024 * 1024 , CompressionType . NONE , 0L , 0L , metrics , time ,
this . accumulator = new RecordAccumulator ( logContext , batchSize , 1024 * 1024 , CompressionType . NONE , 0L , 0L , metrics , time ,
apiVersions , transactionManager ) ;
this . senderMetricsRegistry = new SenderMetricsRegistry ( metricTags . keySet ( ) ) ;
this . sender = new Sender ( loggerFactory , this . client , this . metadata , this . accumulator , true , MAX_REQUEST_SIZE , ACKS_ALL ,
this . sender = new Sender ( logContext , this . client , this . metadata , this . accumulator , true , MAX_REQUEST_SIZE , ACKS_ALL ,
MAX_RETRIES , this . metrics , this . senderMetricsRegistry , this . time , REQUEST_TIMEOUT , 50 , transactionManager , apiVersions ) ;
this . metadata . update ( this . cluster , Collections . < String > emptySet ( ) , time . milliseconds ( ) ) ;
}