This is an automated email from the ASF dual-hosted git repository.
wanghailin pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-seatunnel.git
The following commit(s) were added to refs/heads/dev by this push:
new 82a5c852d [Improve][Connector-V2]console sink output content to slf4j
log (#3745)
82a5c852d is described below
commit 82a5c852d8a4f4b27ea4a3afea901076543487ec
Author: PengYuan <[email protected]>
AuthorDate: Tue Jan 17 17:18:15 2023 +0800
[Improve][Connector-V2]console sink output content to slf4j log (#3745)
* console sink output content to slf4j log
---
docs/en/connector-v2/sink/Console.md | 20 ++++++------
.../locally/quick-start-seatunnel-engine.md | 37 +++++++++++-----------
.../seatunnel/console/sink/ConsoleSinkWriter.java | 15 +++++++--
3 files changed, 41 insertions(+), 31 deletions(-)
diff --git a/docs/en/connector-v2/sink/Console.md
b/docs/en/connector-v2/sink/Console.md
index c3f66ff9d..2985e1350 100644
--- a/docs/en/connector-v2/sink/Console.md
+++ b/docs/en/connector-v2/sink/Console.md
@@ -67,15 +67,17 @@ sink {
* Console print data
```text
-row=1 : XTblOoJMBr, 1968671376
-row=2 : NAoJoFrthI, 1603900622
-row=3 : VHZBzqQAPr, 1713899051
-row=4 : pfUYOOrPgA, 1412123956
-row=5 : dCNFobURas, 202987936
-row=6 : XGWVgFnfWA, 1879270917
-row=7 : KIGOqnLhqe, 430165110
-row=8 : goMdjHlRpX, 288221239
-row=9 : VBtpiNGArV, 1906991577
+2022-12-19 11:01:45,417 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
output rowType: name<STRING>, age<INT>
+2022-12-19 11:01:46,489 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=1: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
CpiOd, 8520946
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=2: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
eQqTs, 1256802974
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=3: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
UsRgO, 2053193072
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=4: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
jDQJj, 1993016602
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=5: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
rqdKp, 1392682764
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=6: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
wCoWN, 986999925
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=7: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
qomTU, 72775247
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=8: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
jcqXR, 1074529204
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=9: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
AkWIO, 1961723427
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=10: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
hBoib, 929089763
```
## Changelog
diff --git a/docs/en/start-v2/locally/quick-start-seatunnel-engine.md
b/docs/en/start-v2/locally/quick-start-seatunnel-engine.md
index 2e9d86b92..4db251e60 100644
--- a/docs/en/start-v2/locally/quick-start-seatunnel-engine.md
+++ b/docs/en/start-v2/locally/quick-start-seatunnel-engine.md
@@ -10,7 +10,7 @@ Before starting, make sure you have downloaded and deployed
SeaTunnel as describ
## Step 2: Add Job Config File to define a job
-Edit `config/seatunnel.streaming.conf.template`, which determines the way and
logic of data input, processing, and output after seatunnel is started.
+Edit `config/v2.batch.conf.template`, which determines the way and logic of
data input, processing, and output after seatunnel is started.
The following is an example of the configuration file, which is the same as
the example application mentioned above.
```hocon
@@ -56,24 +56,23 @@ is a sign that the command ran successfully or not.
The SeaTunnel console will prints some logs as below:
```shell
-fields : name, age
-types : STRING, INT
-row=1 : elWaB, 1984352560
-row=2 : uAtnp, 762961563
-row=3 : TQEIB, 2042675010
-row=4 : DcFjo, 593971283
-row=5 : SenEb, 2099913608
-row=6 : DHjkg, 1928005856
-row=7 : eScCM, 526029657
-row=8 : sgOeE, 600878991
-row=9 : gwdvw, 1951126920
-row=10 : nSiKE, 488708928
-row=11 : xubpl, 1420202810
-row=12 : rHZqb, 331185742
-row=13 : rciGD, 1112878259
-row=14 : qLhdI, 1457046294
-row=15 : ZTkRx, 1240668386
-row=16 : SGZCr, 94186144
+2022-12-19 11:01:45,417 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
output rowType: name<STRING>, age<INT>
+2022-12-19 11:01:46,489 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=1: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
CpiOd, 8520946
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=2: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
eQqTs, 1256802974
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=3: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
UsRgO, 2053193072
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=4: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
jDQJj, 1993016602
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=5: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
rqdKp, 1392682764
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=6: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
wCoWN, 986999925
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=7: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
qomTU, 72775247
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=8: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
jcqXR, 1074529204
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=9: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
AkWIO, 1961723427
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=10: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
hBoib, 929089763
+2022-12-19 11:01:46,490 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=11: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
GSvzm, 827085798
+2022-12-19 11:01:46,491 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=12: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
NNAYI, 94307133
+2022-12-19 11:01:46,491 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=13: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
EexFl, 1823689599
+2022-12-19 11:01:46,491 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=14: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
CBXUb, 869582787
+2022-12-19 11:01:46,491 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=15: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
Wbxtm, 1469371353
+2022-12-19 11:01:46,491 INFO
org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSinkWriter -
subtaskIndex=0 rowIndex=16: SeaTunnelRow#tableId=-1 SeaTunnelRow#kind=INSERT:
mIJDt, 995616438
```
## What's More
diff --git
a/seatunnel-connectors-v2/connector-console/src/main/java/org/apache/seatunnel/connectors/seatunnel/console/sink/ConsoleSinkWriter.java
b/seatunnel-connectors-v2/connector-console/src/main/java/org/apache/seatunnel/connectors/seatunnel/console/sink/ConsoleSinkWriter.java
index 88d0584e7..84bad94b9 100644
---
a/seatunnel-connectors-v2/connector-console/src/main/java/org/apache/seatunnel/connectors/seatunnel/console/sink/ConsoleSinkWriter.java
+++
b/seatunnel-connectors-v2/connector-console/src/main/java/org/apache/seatunnel/connectors/seatunnel/console/sink/ConsoleSinkWriter.java
@@ -24,6 +24,7 @@ import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
import org.apache.seatunnel.common.utils.JsonUtils;
import
org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.lang.reflect.Array;
@@ -31,6 +32,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
+@Slf4j
public class ConsoleSinkWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
private final SeaTunnelRowType seaTunnelRowType;
@@ -40,8 +42,7 @@ public class ConsoleSinkWriter extends
AbstractSinkWriter<SeaTunnelRow, Void> {
public ConsoleSinkWriter(SeaTunnelRowType seaTunnelRowType,
SinkWriter.Context context) {
this.seaTunnelRowType = seaTunnelRowType;
this.context = context;
- System.out.printf("fields : %s%n",
StringUtils.join(seaTunnelRowType.getFieldNames(), ", "));
- System.out.printf("types : %s%n",
StringUtils.join(seaTunnelRowType.getFieldTypes(), ", "));
+ log.info("output rowType: {}", fieldsInfo(seaTunnelRowType));
}
@Override
@@ -53,7 +54,7 @@ public class ConsoleSinkWriter extends
AbstractSinkWriter<SeaTunnelRow, Void> {
for (int i = 0; i < fieldTypes.length; i++) {
arr[i] = fieldToString(fieldTypes[i], fields[i]);
}
- System.out.format("subtaskIndex=%s: row=%s : %s%n",
context.getIndexOfSubtask(), CNT.incrementAndGet(), StringUtils.join(arr, ",
"));
+ log.info("subtaskIndex={} rowIndex={}: SeaTunnelRow#tableId={}
SeaTunnelRow#kind={} : {}", context.getIndexOfSubtask(), CNT.incrementAndGet(),
element.getTableId(), element.getRowKind(), StringUtils.join(arr, ", "));
}
@Override
@@ -61,6 +62,14 @@ public class ConsoleSinkWriter extends
AbstractSinkWriter<SeaTunnelRow, Void> {
// nothing
}
+ private String fieldsInfo(SeaTunnelRowType seaTunnelRowType) {
+ String[] fieldsInfo = new String[seaTunnelRowType.getTotalFields()];
+ for (int i = 0; i < seaTunnelRowType.getTotalFields(); i++) {
+ fieldsInfo[i] = String.format("%s<%s>",
seaTunnelRowType.getFieldName(i), seaTunnelRowType.getFieldType(i));
+ }
+ return StringUtils.join(fieldsInfo, ", ");
+ }
+
private String fieldToString(SeaTunnelDataType<?> type, Object value) {
if (value == null) {
return null;