Open Kilda Java Documentation
KafkaConsumerConfig.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 
21 
22 import com.sabre.oss.conf4j.annotation.Configuration;
23 import com.sabre.oss.conf4j.annotation.Default;
24 import com.sabre.oss.conf4j.annotation.Key;
25 
26 import java.util.Properties;
27 import javax.validation.constraints.Min;
28 
32 @Configuration
34  @Key("kafka-groupid")
35  @Default("floodlight")
37  String getGroupId();
38 
39  @Key("testing-mode")
40  String getTestingMode();
41 
42  @Key("consumer-executors")
43  @Default("10")
44  @Min(1)
45  int getExecutorCount();
46 
47  @Key("consumer-auto-commit-interval")
48  @Default("1000")
49  @Min(1)
50  long getAutoCommitInterval();
51 
52  default boolean isTestingMode() {
53  return "YES".equals(getTestingMode());
54  }
55 
59  default Properties createKafkaConsumerProperties() {
60  Properties properties = new Properties();
61  properties.put("bootstrap.servers", getBootstrapServers());
62 
63  properties.put("group.id", getGroupId());
64  properties.put("session.timeout.ms", "30000");
65  properties.put("enable.auto.commit", "false");
66 
67  properties.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
68  properties.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
69 
70  return properties;
71  }
72 }
target
Definition: nodes.py:50