|
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"; |
| 47 | + |
| 48 | + private String bootstrapServers; |
37 | 49 |
|
38 | | - public static final String BOOTSTRAPSERVERS_KEY = "bootstrapServers"; |
| 50 | + private String topic; |
39 | 51 |
|
40 | | - public static final String TOPIC_KEY = "topic"; |
| 52 | + private String groupId; |
41 | 53 |
|
42 | | - public static final String GROUPID_KEY = "groupId"; |
| 54 | + //latest, earliest |
| 55 | + private String offsetReset = "latest"; |
43 | 56 |
|
44 | | - private String bootstrapServers; |
| 57 | + private String offset; |
45 | 58 |
|
46 | | - private String topic; |
| 59 | + private Boolean topicIsPattern = false; |
47 | 60 |
|
48 | | - private String groupId; |
| 61 | + public Boolean getTopicIsPattern() { |
| 62 | + return topicIsPattern; |
| 63 | + } |
49 | 64 |
|
50 | | - //latest, earliest |
51 | | - private String offsetReset = "latest"; |
| 65 | + public void setTopicIsPattern(Boolean topicIsPattern) { |
| 66 | + if (topicIsPattern == null) return; |
52 | 67 |
|
53 | | - private String offset; |
| 68 | + this.topicIsPattern = topicIsPattern; |
| 69 | + } |
54 | 70 |
|
55 | | - public KafkaSourceTableInfo(){ |
56 | | - super.setType(CURR_TYPE); |
57 | | - } |
| 71 | + public KafkaSourceTableInfo() { |
| 72 | + super.setType(CURR_TYPE); |
| 73 | + } |
58 | 74 |
|
59 | 75 |
|
60 | | - public String getBootstrapServers() { |
61 | | - return bootstrapServers; |
62 | | - } |
| 76 | + public String getBootstrapServers() { |
| 77 | + return bootstrapServers; |
| 78 | + } |
63 | 79 |
|
64 | | - public void setBootstrapServers(String bootstrapServers) { |
65 | | - this.bootstrapServers = bootstrapServers; |
66 | | - } |
| 80 | + public void setBootstrapServers(String bootstrapServers) { |
| 81 | + this.bootstrapServers = bootstrapServers; |
| 82 | + } |
67 | 83 |
|
68 | | - public String getTopic() { |
69 | | - return topic; |
70 | | - } |
| 84 | + public String getTopic() { |
| 85 | + return topic; |
| 86 | + } |
71 | 87 |
|
72 | | - public void setTopic(String topic) { |
73 | | - this.topic = topic; |
74 | | - } |
| 88 | + public void setTopic(String topic) { |
| 89 | + this.topic = topic; |
| 90 | + } |
75 | 91 |
|
76 | | - public String getGroupId() { |
77 | | - return groupId; |
78 | | - } |
| 92 | + public String getGroupId() { |
| 93 | + return groupId; |
| 94 | + } |
79 | 95 |
|
80 | | - public void setGroupId(String groupId) { |
81 | | - this.groupId = groupId; |
82 | | - } |
| 96 | + public void setGroupId(String groupId) { |
| 97 | + this.groupId = groupId; |
| 98 | + } |
83 | 99 |
|
84 | | - public String getOffsetReset() { |
85 | | - return offsetReset; |
86 | | - } |
| 100 | + public String getOffsetReset() { |
| 101 | + return offsetReset; |
| 102 | + } |
87 | 103 |
|
88 | | - public void setOffsetReset(String offsetReset) { |
89 | | - if(offsetReset == null){ |
90 | | - return; |
91 | | - } |
| 104 | + public void setOffsetReset(String offsetReset) { |
| 105 | + if (offsetReset == null) { |
| 106 | + return; |
| 107 | + } |
92 | 108 |
|
93 | | - this.offsetReset = offsetReset; |
94 | | - } |
| 109 | + this.offsetReset = offsetReset; |
| 110 | + } |
95 | 111 |
|
96 | | - public String getOffset() { |
97 | | - return offset; |
98 | | - } |
| 112 | + public String getOffset() { |
| 113 | + return offset; |
| 114 | + } |
99 | 115 |
|
100 | | - public void setOffset(String offset) { |
101 | | - this.offset = offset; |
102 | | - } |
| 116 | + public void setOffset(String offset) { |
| 117 | + this.offset = offset; |
| 118 | + } |
103 | 119 |
|
104 | | - @Override |
105 | | - public boolean check() { |
106 | | - Preconditions.checkNotNull(bootstrapServers, "kafka of bootstrapServers is required"); |
107 | | - Preconditions.checkNotNull(topic, "kafka of topic is required"); |
108 | | - Preconditions.checkNotNull(groupId, "kafka of groupId is required"); |
109 | | - Preconditions.checkState(offsetReset.equalsIgnoreCase("latest") |
110 | | - || 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"); |
111 | 127 |
|
112 | | - return false; |
113 | | - } |
| 128 | + return false; |
| 129 | + } |
114 | 130 |
|
115 | | - @Override |
116 | | - public String getType() { |
| 131 | + @Override |
| 132 | + public String getType() { |
117 | 133 | // return super.getType() + SOURCE_SUFFIX; |
118 | | - return super.getType(); |
119 | | - } |
| 134 | + return super.getType(); |
| 135 | + } |
120 | 136 | } |
0 commit comments