|
16 | 16 | * limitations under the License. |
17 | 17 | */ |
18 | 18 |
|
19 | | - |
20 | 19 |
|
21 | 20 | package com.dtstack.flink.sql.source.kafka.table; |
22 | 21 |
|
|
27 | 26 | * Reason: |
28 | 27 | * Date: 2018/6/22 |
29 | 28 | * Company: www.dtstack.com |
| 29 | + * |
30 | 30 | * @author xuchao |
31 | 31 | */ |
32 | 32 |
|
33 | 33 | public class KafkaSourceTableInfo extends SourceTableInfo { |
34 | 34 |
|
35 | | - //version |
36 | | - private static final String CURR_TYPE = "kafka09"; |
| 35 | + //version |
| 36 | + private static final String CURR_TYPE = "kafka09"; |
| 37 | + |
| 38 | + public static final String BOOTSTRAPSERVERS_KEY = "bootstrapServers"; |
| 39 | + |
| 40 | + public static final String TOPIC_KEY = "topic"; |
| 41 | + |
| 42 | + public static final String GROUPID_KEY = "groupId"; |
| 43 | + |
| 44 | + public static final String OFFSETRESET_KEY = "offsetReset"; |
| 45 | + |
| 46 | + public static final String TOPICISPATTERN_KEY = "topicIsPattern"; |
37 | 47 |
|
38 | | - public static final String BOOTSTRAPSERVERS_KEY = "bootstrapServers"; |
| 48 | + private String bootstrapServers; |
39 | 49 |
|
40 | | - public static final String TOPIC_KEY = "topic"; |
| 50 | + private String topic; |
41 | 51 |
|
42 | | - public static final String GROUPID_KEY = "groupId"; |
| 52 | + private String groupId; |
43 | 53 |
|
44 | | - public static final String OFFSETRESET_KEY="offsetReset"; |
| 54 | + //latest, earliest |
| 55 | + private String offsetReset = "latest"; |
45 | 56 |
|
46 | | - private String bootstrapServers; |
| 57 | + private String offset; |
47 | 58 |
|
48 | | - private String topic; |
| 59 | + private Boolean topicIsPattern = false; |
49 | 60 |
|
50 | | - private String groupId; |
| 61 | + public Boolean getTopicIsPattern() { |
| 62 | + return topicIsPattern; |
| 63 | + } |
51 | 64 |
|
52 | | - //latest, earliest |
53 | | - private String offsetReset = "latest"; |
| 65 | + public void setTopicIsPattern(Boolean topicIsPattern) { |
| 66 | + if (topicIsPattern == null) return; |
54 | 67 |
|
55 | | - private String offset; |
| 68 | + this.topicIsPattern = topicIsPattern; |
| 69 | + } |
56 | 70 |
|
57 | | - public KafkaSourceTableInfo(){ |
58 | | - super.setType(CURR_TYPE); |
59 | | - } |
| 71 | + public KafkaSourceTableInfo() { |
| 72 | + super.setType(CURR_TYPE); |
| 73 | + } |
60 | 74 |
|
61 | 75 |
|
62 | | - public String getBootstrapServers() { |
63 | | - return bootstrapServers; |
64 | | - } |
| 76 | + public String getBootstrapServers() { |
| 77 | + return bootstrapServers; |
| 78 | + } |
65 | 79 |
|
66 | | - public void setBootstrapServers(String bootstrapServers) { |
67 | | - this.bootstrapServers = bootstrapServers; |
68 | | - } |
| 80 | + public void setBootstrapServers(String bootstrapServers) { |
| 81 | + this.bootstrapServers = bootstrapServers; |
| 82 | + } |
69 | 83 |
|
70 | | - public String getTopic() { |
71 | | - return topic; |
72 | | - } |
| 84 | + public String getTopic() { |
| 85 | + return topic; |
| 86 | + } |
73 | 87 |
|
74 | | - public void setTopic(String topic) { |
75 | | - this.topic = topic; |
76 | | - } |
| 88 | + public void setTopic(String topic) { |
| 89 | + this.topic = topic; |
| 90 | + } |
77 | 91 |
|
78 | | - public String getGroupId() { |
79 | | - return groupId; |
80 | | - } |
| 92 | + public String getGroupId() { |
| 93 | + return groupId; |
| 94 | + } |
81 | 95 |
|
82 | | - public void setGroupId(String groupId) { |
83 | | - this.groupId = groupId; |
84 | | - } |
| 96 | + public void setGroupId(String groupId) { |
| 97 | + this.groupId = groupId; |
| 98 | + } |
85 | 99 |
|
86 | | - public String getOffsetReset() { |
87 | | - return offsetReset; |
88 | | - } |
| 100 | + public String getOffsetReset() { |
| 101 | + return offsetReset; |
| 102 | + } |
89 | 103 |
|
90 | | - public void setOffsetReset(String offsetReset) { |
91 | | - if(offsetReset == null){ |
92 | | - return; |
93 | | - } |
| 104 | + public void setOffsetReset(String offsetReset) { |
| 105 | + if (offsetReset == null) { |
| 106 | + return; |
| 107 | + } |
94 | 108 |
|
95 | | - this.offsetReset = offsetReset; |
96 | | - } |
| 109 | + this.offsetReset = offsetReset; |
| 110 | + } |
97 | 111 |
|
98 | | - public String getOffset() { |
99 | | - return offset; |
100 | | - } |
| 112 | + public String getOffset() { |
| 113 | + return offset; |
| 114 | + } |
101 | 115 |
|
102 | | - public void setOffset(String offset) { |
103 | | - this.offset = offset; |
104 | | - } |
| 116 | + public void setOffset(String offset) { |
| 117 | + this.offset = offset; |
| 118 | + } |
105 | 119 |
|
106 | | - @Override |
107 | | - public boolean check() { |
108 | | - Preconditions.checkNotNull(bootstrapServers, "kafka of bootstrapServers is required"); |
109 | | - Preconditions.checkNotNull(topic, "kafka of topic is required"); |
110 | | - Preconditions.checkNotNull(groupId, "kafka of groupId is required"); |
111 | | - Preconditions.checkState(offsetReset.equalsIgnoreCase("latest") |
112 | | - || offsetReset.equalsIgnoreCase("latest"), "kafka of offsetReset set fail"); |
| 120 | + @Override |
| 121 | + public boolean check() { |
| 122 | + Preconditions.checkNotNull(bootstrapServers, "kafka of bootstrapServers is required"); |
| 123 | + Preconditions.checkNotNull(topic, "kafka of topic is required"); |
| 124 | + Preconditions.checkNotNull(groupId, "kafka of groupId is required"); |
| 125 | + Preconditions.checkState(offsetReset.equalsIgnoreCase("latest") |
| 126 | + || offsetReset.equalsIgnoreCase("latest"), "kafka of offsetReset set fail"); |
113 | 127 |
|
114 | | - return false; |
115 | | - } |
| 128 | + return false; |
| 129 | + } |
116 | 130 |
|
117 | | - @Override |
118 | | - public String getType() { |
| 131 | + @Override |
| 132 | + public String getType() { |
119 | 133 | // return super.getType() + SOURCE_SUFFIX; |
120 | | - return super.getType(); |
121 | | - } |
| 134 | + return super.getType(); |
| 135 | + } |
122 | 136 | } |
0 commit comments