Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improve]Change System.out.println to log output. #5912

Merged
merged 4 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.net.URL;
import java.nio.file.Paths;
Expand All @@ -37,6 +39,7 @@

import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_DEFAULT;

@Slf4j
public class OrcReadStrategyTest {

@Test
Expand All @@ -51,7 +54,7 @@ public void testOrcRead() throws Exception {
SeaTunnelRowType seaTunnelRowTypeInfo =
orcReadStrategy.getSeaTunnelRowTypeInfo(localConf, orcFilePath);
Assertions.assertNotNull(seaTunnelRowTypeInfo);
System.out.println(seaTunnelRowTypeInfo);
log.info(seaTunnelRowTypeInfo.toString());
orcReadStrategy.read(orcFilePath, "", testCollector);
for (SeaTunnelRow row : testCollector.getRows()) {
Assertions.assertEquals(row.getField(0).getClass(), Boolean.class);
Expand All @@ -77,7 +80,7 @@ public void testOrcReadProjection() throws Exception {
SeaTunnelRowType seaTunnelRowTypeInfo =
orcReadStrategy.getSeaTunnelRowTypeInfo(localConf, orcFilePath);
Assertions.assertNotNull(seaTunnelRowTypeInfo);
System.out.println(seaTunnelRowTypeInfo);
log.info(seaTunnelRowTypeInfo.toString());
orcReadStrategy.read(orcFilePath, "", testCollector);
for (SeaTunnelRow row : testCollector.getRows()) {
Assertions.assertEquals(row.getField(0).getClass(), Byte.class);
Expand All @@ -95,7 +98,7 @@ public List<SeaTunnelRow> getRows() {

@Override
public void collect(SeaTunnelRow record) {
System.out.println(record);
log.info(record.toString());
rows.add(record);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.net.URL;
import java.nio.file.Paths;
Expand All @@ -39,6 +41,7 @@

import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_DEFAULT;

@Slf4j
public class ParquetReadStrategyTest {
@Test
public void testParquetRead1() throws Exception {
Expand All @@ -51,7 +54,7 @@ public void testParquetRead1() throws Exception {
SeaTunnelRowType seaTunnelRowTypeInfo =
parquetReadStrategy.getSeaTunnelRowTypeInfo(localConf, path);
Assertions.assertNotNull(seaTunnelRowTypeInfo);
System.out.println(seaTunnelRowTypeInfo);
log.info(seaTunnelRowTypeInfo.toString());
TestCollector testCollector = new TestCollector();
parquetReadStrategy.read(path, "", testCollector);
}
Expand All @@ -67,7 +70,7 @@ public void testParquetRead2() throws Exception {
SeaTunnelRowType seaTunnelRowTypeInfo =
parquetReadStrategy.getSeaTunnelRowTypeInfo(localConf, path);
Assertions.assertNotNull(seaTunnelRowTypeInfo);
System.out.println(seaTunnelRowTypeInfo);
log.info(seaTunnelRowTypeInfo.toString());
TestCollector testCollector = new TestCollector();
parquetReadStrategy.read(path, "", testCollector);
}
Expand All @@ -83,7 +86,7 @@ public void testParquetReadUseSystemDefaultTimeZone() throws Exception {
SeaTunnelRowType seaTunnelRowTypeInfo =
parquetReadStrategy.getSeaTunnelRowTypeInfo(localConf, path);
Assertions.assertNotNull(seaTunnelRowTypeInfo);
System.out.println(seaTunnelRowTypeInfo);
log.info(seaTunnelRowTypeInfo.toString());
int index = seaTunnelRowTypeInfo.indexOf("c_timestamp");
TimeZone tz1 = TimeZone.getTimeZone("Asia/Shanghai");
TimeZone.setDefault(tz1);
Expand Down Expand Up @@ -119,7 +122,7 @@ public void testParquetReadProjection1() throws Exception {
SeaTunnelRowType seaTunnelRowTypeInfo =
parquetReadStrategy.getSeaTunnelRowTypeInfo(localConf, path);
Assertions.assertNotNull(seaTunnelRowTypeInfo);
System.out.println(seaTunnelRowTypeInfo);
log.info(seaTunnelRowTypeInfo.toString());
TestCollector testCollector = new TestCollector();
parquetReadStrategy.read(path, "", testCollector);
List<SeaTunnelRow> rows = testCollector.getRows();
Expand Down Expand Up @@ -149,7 +152,7 @@ public void testParquetReadProjection2() throws Exception {
SeaTunnelRowType seaTunnelRowTypeInfo =
parquetReadStrategy.getSeaTunnelRowTypeInfo(localConf, path);
Assertions.assertNotNull(seaTunnelRowTypeInfo);
System.out.println(seaTunnelRowTypeInfo);
log.info(seaTunnelRowTypeInfo.toString());
TestCollector testCollector = new TestCollector();
parquetReadStrategy.read(path, "", testCollector);
}
Expand All @@ -164,7 +167,7 @@ public List<SeaTunnelRow> getRows() {

@Override
public void collect(SeaTunnelRow record) {
System.out.println(record);
log.info(record.toString());
rows.add(record);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import lombok.extern.slf4j.Slf4j;

@Disabled("Please Test it in your local environment")
@Slf4j
class PostgresCatalogTest {

@Test
Expand All @@ -51,7 +54,7 @@ void testCatalog() {

CatalogTable table =
catalog.getTable(TablePath.of("st_test", "public", "all_types_table_02"));
System.out.println("find table: " + table);
log.info("find table: " + table);

catalog.createTable(
new TablePath("liulitest", "public", "all_types_table_02"), table, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Slf4j
public class StarRocksCreateTableTest {

@Test
Expand Down Expand Up @@ -71,7 +74,7 @@ public void test() {
.columns(columns)
.build());

System.out.println(result);
log.info(result);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
import org.apache.seatunnel.core.starter.flink.args.FlinkCommandArgs;
import org.apache.seatunnel.core.starter.utils.CommandLineUtils;

import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/** The SeaTunnel flink starter, used to generate the final flink job execute command. */
@Slf4j
public class FlinkStarter implements Starter {
private static final String APP_NAME = SeaTunnelFlink.class.getName();
public static final String APP_JAR_NAME = EngineType.FLINK13.getStarterJarName();
Expand All @@ -46,7 +49,7 @@ public class FlinkStarter implements Starter {

public static void main(String[] args) {
FlinkStarter flinkStarter = new FlinkStarter(args);
System.out.println(String.join(" ", flinkStarter.buildCommands()));
log.info(String.join(" ", flinkStarter.buildCommands()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
import org.apache.seatunnel.core.starter.flink.args.FlinkCommandArgs;
import org.apache.seatunnel.core.starter.utils.CommandLineUtils;

import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/** The SeaTunnel flink starter, used to generate the final flink job execute command. */
@Slf4j
public class FlinkStarter implements Starter {
private static final String APP_NAME = SeaTunnelFlink.class.getName();
public static final String APP_JAR_NAME = EngineType.FLINK15.getStarterJarName();
Expand All @@ -46,7 +49,7 @@ public class FlinkStarter implements Starter {

public static void main(String[] args) {
FlinkStarter flinkStarter = new FlinkStarter(args);
System.out.println(String.join(" ", flinkStarter.buildCommands()));
log.info(String.join(" ", flinkStarter.buildCommands()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

import org.apache.commons.lang3.StringUtils;

import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
Expand All @@ -58,6 +60,7 @@
import java.util.stream.Stream;

/** A Starter to generate spark-submit command for SeaTunnel job on spark. */
@Slf4j
public class SparkStarter implements Starter {

/** original commandline args */
Expand All @@ -83,7 +86,7 @@ private SparkStarter(String[] args, SparkCommandArgs commandArgs) {
public static void main(String[] args) throws IOException {
SparkStarter starter = getInstance(args);
List<String> command = starter.buildCommands();
System.out.println(String.join(" ", command));
log.info(String.join(" ", command));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

import org.apache.commons.lang3.StringUtils;

import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
Expand All @@ -58,6 +60,7 @@
import java.util.stream.Stream;

/** A Starter to generate spark-submit command for SeaTunnel job on spark. */
@Slf4j
public class SparkStarter implements Starter {

/** original commandline args */
Expand All @@ -83,7 +86,7 @@ private SparkStarter(String[] args, SparkCommandArgs commandArgs) {
public static void main(String[] args) throws IOException {
SparkStarter starter = getInstance(args);
List<String> command = starter.buildCommands();
System.out.println(String.join(" ", command));
log.info(String.join(" ", command));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ public void execute() throws CommandExecuteException {
engineClient = new SeaTunnelClient(clientConfig);
if (clientCommandArgs.isListJob()) {
String jobStatus = engineClient.getJobClient().listJobStatus(true);
System.out.println(jobStatus);
log.info(jobStatus);
} else if (clientCommandArgs.isGetRunningJobMetrics()) {
String runningJobMetrics = engineClient.getJobClient().getRunningJobMetrics();
System.out.println(runningJobMetrics);
log.info(runningJobMetrics);
} else if (null != clientCommandArgs.getJobId()) {
String jobState =
engineClient
.getJobClient()
.getJobDetailStatus(Long.parseLong(clientCommandArgs.getJobId()));
System.out.println(jobState);
log.info(jobState);
} else if (null != clientCommandArgs.getCancelJobId()) {
engineClient
.getJobClient()
Expand All @@ -114,7 +114,7 @@ public void execute() throws CommandExecuteException {
engineClient
.getJobClient()
.getJobMetrics(Long.parseLong(clientCommandArgs.getMetricsJobId()));
System.out.println(jobMetrics);
log.info(jobMetrics);
} else if (null != clientCommandArgs.getSavePointJobId()) {
engineClient
.getJobClient()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void testBatchJobRunOkIn2Node() throws ExecutionException, InterruptedExc
Long fileLineNumberFromDir =
FileUtils.getFileLineNumberFromDir(testResources.getLeft());
Assertions.assertEquals(testRowNumber * testParallelism, fileLineNumberFromDir);
System.out.println(engineClient.getJobMetrics(clientJobProxy.getJobId()));
log.info(engineClient.getJobMetrics(clientJobProxy.getJobId()));
log.warn("========================clean test resource====================");
} finally {
if (engineClient != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public void getClusterHealthMetrics() {
engineClient = new SeaTunnelClient(clientConfig);

Map<String, String> clusterHealthMetrics = engineClient.getClusterHealthMetrics();
System.out.println(
log.info(
"=====================================cluster metrics==================================================");
for (Map.Entry<String, String> entry : clusterHealthMetrics.entrySet()) {
System.out.println(entry.getKey());
System.out.println(entry.getValue());
System.out.println(
log.info(entry.getKey());
log.info(entry.getValue());
log.info(
"======================================================================================================");
}
Assertions.assertEquals(2, clusterHealthMetrics.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.instance.impl.HazelcastInstanceFactory;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
Expand All @@ -57,6 +58,7 @@
import static org.awaitility.Awaitility.await;

@DisabledOnOs(OS.WINDOWS)
@Slf4j
public class SeaTunnelClientTest {

private static SeaTunnelConfig SEATUNNEL_CONFIG = ConfigProvider.locateAndGetSeaTunnelConfig();
Expand Down Expand Up @@ -201,7 +203,7 @@ public void testGetJobMetrics() {

String jobMetrics = jobClient.getJobMetrics(jobId);

System.out.println(jobMetrics);
log.info(jobMetrics);

Assertions.assertTrue(jobMetrics.contains(SOURCE_RECEIVED_COUNT));
Assertions.assertTrue(jobMetrics.contains(SOURCE_RECEIVED_QPS));
Expand Down Expand Up @@ -258,7 +260,7 @@ public void testGetRunningJobMetrics() throws ExecutionException, InterruptedExc
.getJobStatus(jobId3)
.equals("RUNNING")));

System.out.println(jobClient.getRunningJobMetrics());
log.info(jobClient.getRunningJobMetrics());

await().atMost(30000, TimeUnit.MILLISECONDS)
.untilAsserted(
Expand Down Expand Up @@ -334,10 +336,10 @@ public void testGetJobInfo() {
.untilAsserted(
() -> {
Thread.sleep(1000);
System.out.println(
log.info(
"======================job status:"
+ jobClient.getJobDetailStatus(jobId));
System.out.println(
log.info(
"======================list job status:"
+ jobClient.listJobStatus(true));
Assertions.assertTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ public void testContentFormatUtil() throws InterruptedException {
return s1.getSubmitTime() > s2.getSubmitTime() ? -1 : 1;
});
String r = ContentFormatUtil.format(statusDataList);
System.out.println(r);
log.info(r);
}
}
Loading