Browse Source

Options in SyncProducerConfig and AsyncProducerConfig can leak, KAFKA-83

git-svn-id: https://svn.apache.org/repos/asf/incubator/kafka/trunk@1154804 13f79535-47bb-0310-9956-ffa450edef68
0.7.0
Jun Rao 13 years ago
parent
commit
f7046c247d
  1. 17
      core/src/main/scala/kafka/producer/ProducerPool.scala

17
core/src/main/scala/kafka/producer/ProducerPool.scala

@ -69,24 +69,15 @@ class ProducerPool[V](private val config: ProducerConfig, @@ -69,24 +69,15 @@ class ProducerPool[V](private val config: ProducerConfig,
* @param port the port of the broker
*/
def addProducer(broker: Broker) {
val props = new Properties()
props.put("host", broker.host)
props.put("port", broker.port.toString)
props.putAll(config.props)
if(sync) {
val props = new Properties()
props.put("host", broker.host)
props.put("port", broker.port.toString)
props.put("buffer.size", config.bufferSize.toString)
props.put("connect.timeout.ms", config.connectTimeoutMs.toString)
props.put("reconnect.interval", config.reconnectInterval.toString)
val producer = new SyncProducer(new SyncProducerConfig(props))
logger.info("Creating sync producer for broker id = " + broker.id + " at " + broker.host + ":" + broker.port)
syncProducers.put(broker.id, producer)
} else {
val props = new Properties()
props.put("host", broker.host)
props.put("port", broker.port.toString)
props.put("queue.time", config.queueTime.toString)
props.put("queue.size", config.queueSize.toString)
props.put("batch.size", config.batchSize.toString)
props.put("serializer.class", config.serializerClass)
val producer = new AsyncProducer[V](new AsyncProducerConfig(props),
new SyncProducer(new SyncProducerConfig(props)),
serializer,

Loading…
Cancel
Save