Open Kilda Java Documentation
KafkaProducerConfig.java
Go to the documentation of this file.
1 /* Copyright 2018 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.floodlight.kafka;
17 
19 
20 import com.sabre.oss.conf4j.annotation.Configuration;
21 import com.sabre.oss.conf4j.annotation.Default;
22 import com.sabre.oss.conf4j.annotation.Key;
23 
24 import java.util.Properties;
25 import javax.validation.constraints.Min;
26 
30 @Configuration
31 public interface KafkaProducerConfig extends KafkaFloodlightConfig {
32  @Key("testing-mode")
33  String getTestingMode();
34 
35  @Key("heart-beat-interval")
36  @Default("1")
37  @Min(1)
38  float getHeartBeatInterval();
39 
40  default boolean isTestingMode() {
41  return "YES".equals(getTestingMode());
42  }
43 
47  default Properties createKafkaProducerProperties() {
48  Properties properties = new Properties();
49  properties.put("bootstrap.servers", getBootstrapServers());
50 
51  properties.put("acks", "all");
52  properties.put("retries", 0);
53  properties.put("batch.size", 4);
54  properties.put("buffer.memory", 33554432);
55  properties.put("linger.ms", 10);
56 
57  properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
58  properties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
59 
60  return properties;
61  }
62 }