Skip to content

Commit c439b99

Browse files
authored
[improve] console sink options (#8743)
1 parent d66d9dc commit c439b99

File tree

4 files changed

+44
-26
lines changed

4 files changed

+44
-26
lines changed

seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/ConnectorOptionCheckTest.java

-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ private Set<String> buildWhiteList() {
208208
whiteList.add("SocketSinkOptions");
209209
whiteList.add("ClickhouseSinkOptions");
210210
whiteList.add("SelectDBSinkOptions");
211-
whiteList.add("ConsoleSinkOptions");
212211
whiteList.add("PrometheusSinkOptions");
213212
whiteList.add("FirestoreSinkOptions");
214213
whiteList.add("ClickhouseSourceOptions");

seatunnel-connectors-v2/connector-console/src/main/java/org/apache/seatunnel/connectors/seatunnel/console/sink/ConsoleSink.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
import java.util.List;
3232
import java.util.Optional;
3333

34-
import static org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkFactory.LOG_PRINT_DATA;
35-
import static org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkFactory.LOG_PRINT_DELAY;
36-
3734
public class ConsoleSink extends AbstractSimpleSink<SeaTunnelRow, Void>
3835
implements SupportMultiTableSink, SupportSchemaEvolutionSink {
3936
private final SeaTunnelRowType seaTunnelRowType;
@@ -43,8 +40,8 @@ public class ConsoleSink extends AbstractSimpleSink<SeaTunnelRow, Void>
4340

4441
public ConsoleSink(CatalogTable catalogTable, ReadonlyConfig options) {
4542
this.catalogTable = catalogTable;
46-
this.isPrintData = options.get(LOG_PRINT_DATA);
47-
this.delayMs = options.get(LOG_PRINT_DELAY);
43+
this.isPrintData = options.get(ConsoleSinkOptions.LOG_PRINT_DATA);
44+
this.delayMs = options.get(ConsoleSinkOptions.LOG_PRINT_DELAY);
4845
this.seaTunnelRowType = catalogTable.getTableSchema().toPhysicalRowDataType();
4946
}
5047

seatunnel-connectors-v2/connector-console/src/main/java/org/apache/seatunnel/connectors/seatunnel/console/sink/ConsoleSinkFactory.java

+3-20
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@
1717

1818
package org.apache.seatunnel.connectors.seatunnel.console.sink;
1919

20-
import org.apache.seatunnel.api.configuration.Option;
21-
import org.apache.seatunnel.api.configuration.Options;
2220
import org.apache.seatunnel.api.configuration.ReadonlyConfig;
2321
import org.apache.seatunnel.api.configuration.util.OptionRule;
24-
import org.apache.seatunnel.api.options.SinkConnectorCommonOptions;
2522
import org.apache.seatunnel.api.table.connector.TableSink;
2623
import org.apache.seatunnel.api.table.factory.Factory;
2724
import org.apache.seatunnel.api.table.factory.TableSinkFactory;
@@ -32,20 +29,6 @@
3229
@AutoService(Factory.class)
3330
public class ConsoleSinkFactory implements TableSinkFactory {
3431

35-
public static final Option<Boolean> LOG_PRINT_DATA =
36-
Options.key("log.print.data")
37-
.booleanType()
38-
.defaultValue(true)
39-
.withDescription(
40-
"Flag to determine whether data should be printed in the logs.");
41-
42-
public static final Option<Integer> LOG_PRINT_DELAY =
43-
Options.key("log.print.delay.ms")
44-
.intType()
45-
.defaultValue(0)
46-
.withDescription(
47-
"Delay in milliseconds between printing each data item to the logs.");
48-
4932
@Override
5033
public String factoryIdentifier() {
5134
return "Console";
@@ -55,9 +38,9 @@ public String factoryIdentifier() {
5538
public OptionRule optionRule() {
5639
return OptionRule.builder()
5740
.optional(
58-
LOG_PRINT_DATA,
59-
LOG_PRINT_DELAY,
60-
SinkConnectorCommonOptions.MULTI_TABLE_SINK_REPLICA)
41+
ConsoleSinkOptions.LOG_PRINT_DATA,
42+
ConsoleSinkOptions.LOG_PRINT_DELAY,
43+
ConsoleSinkOptions.MULTI_TABLE_SINK_REPLICA)
6144
.build();
6245
}
6346

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.seatunnel.connectors.seatunnel.console.sink;
19+
20+
import org.apache.seatunnel.api.configuration.Option;
21+
import org.apache.seatunnel.api.configuration.Options;
22+
import org.apache.seatunnel.api.options.SinkConnectorCommonOptions;
23+
24+
public class ConsoleSinkOptions extends SinkConnectorCommonOptions {
25+
26+
public static final Option<Boolean> LOG_PRINT_DATA =
27+
Options.key("log.print.data")
28+
.booleanType()
29+
.defaultValue(true)
30+
.withDescription(
31+
"Flag to determine whether data should be printed in the logs.");
32+
33+
public static final Option<Integer> LOG_PRINT_DELAY =
34+
Options.key("log.print.delay.ms")
35+
.intType()
36+
.defaultValue(0)
37+
.withDescription(
38+
"Delay in milliseconds between printing each data item to the logs.");
39+
}

0 commit comments

Comments
 (0)