File tree 3 files changed +54
-7
lines changed
flink-connector-aws/flink-connector-redshift/src/main/java/org/apache/flink/connector/redshift
3 files changed +54
-7
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ package org .apache .flink .connector .redshift .mode ;
20
+
21
+ /** Enum to Define different Modes of Sink supported in Redshift. */
22
+ public enum SinkMode {
23
+ JDBC ,
24
+ COPY
25
+ }
Original file line number Diff line number Diff line change 20
20
21
21
import org .apache .flink .configuration .ConfigOption ;
22
22
import org .apache .flink .configuration .ConfigOptions ;
23
+ import org .apache .flink .connector .redshift .mode .SinkMode ;
23
24
24
25
import java .time .Duration ;
25
26
28
29
/** Constants to be used with the RedshiftSink. */
29
30
public class RedshiftSinkConfigConstants {
30
31
31
- /** Enum to Define different Modes of Sink supported in Redshift. */
32
- public enum SinkMode {
33
- JDBC ,
34
- COPY
35
- }
36
-
37
32
public static final ConfigOption <String > HOSTNAME =
38
33
ConfigOptions .key ("hostname" )
39
34
.stringType ()
Original file line number Diff line number Diff line change 19
19
package org .apache .flink .connector .redshift .sink .config ;
20
20
21
21
import org .apache .flink .configuration .Configuration ;
22
+ import org .apache .flink .util .FlinkRuntimeException ;
22
23
23
24
/** Utility functions to use with {@link RedshiftSinkConfigConstants}. */
24
25
public class RedshiftSinkConfigUtil {
25
26
26
27
// private constructor to prevent initialization of utility class.
27
28
private RedshiftSinkConfigUtil () {}
28
29
29
- public static void validateConfigs (final Configuration sinkConfig ) {}
30
+ public static void validateConfigs (final Configuration sinkConfig )
31
+ throws FlinkRuntimeException {
32
+ switch (sinkConfig .get (RedshiftSinkConfigConstants .SINK_MODE ).toString ()) {
33
+ case "JDBC" :
34
+ validateJdbcAssociatedConfigs (sinkConfig );
35
+ break ;
36
+ case "COPY" :
37
+ validateCopyAssociatedConfigs (sinkConfig );
38
+ break ;
39
+ default :
40
+ throw new FlinkRuntimeException ("Invalid Sink Mode" );
41
+ }
42
+ }
43
+
44
+ private static void validateJdbcAssociatedConfigs (Configuration sinkConfig ) {
45
+ if (sinkConfig .getString (RedshiftSinkConfigConstants .HOSTNAME ).trim ().length () < 3
46
+ || sinkConfig .getInteger (RedshiftSinkConfigConstants .PORT ) < 0 ) {
47
+ throw new FlinkRuntimeException ("Invalid configuration" );
48
+ }
49
+ }
50
+
51
+ private static void validateCopyAssociatedConfigs (Configuration sinkConfig ) {
52
+ if (sinkConfig .getString (RedshiftSinkConfigConstants .S3_URI ) == null
53
+ || sinkConfig .getString (RedshiftSinkConfigConstants .IAM_ROLE_ARN ) == null ) {
54
+ throw new FlinkRuntimeException ("Invalid Configuration" );
55
+ }
56
+ }
30
57
}
You can’t perform that action at this time.
0 commit comments