Skip to content

Commit

Permalink
chore: remove unnecessary logs, update dependencies' version (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
arjenzhou authored Sep 18, 2021
1 parent dea86b7 commit e26e476
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 24 deletions.
9 changes: 9 additions & 0 deletions api/src/main/java/de/xab/porter/api/task/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
*/
public final class Properties {
private String channel = "default";
private String reporter = "default";

public String getReporter() {
return reporter;
}

public void setReporter(String reporter) {
this.reporter = reporter;
}

public String getChannel() {
return channel;
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/de/xab/porter/core/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.xab.porter.api.dataconnection.SinkConnection;
import de.xab.porter.api.dataconnection.SrcConnection;
import de.xab.porter.api.task.Context;
import de.xab.porter.api.task.Properties;
import de.xab.porter.common.spi.ExtensionLoader;
import de.xab.porter.common.util.Loggers;
import de.xab.porter.transfer.channel.Channel;
Expand Down Expand Up @@ -44,9 +45,10 @@ public void init() {
* construct relations among reader, writer and its channel, define the action when channel is ready to write
*/
public void register() {
Properties properties = context.getProperties();
List<SinkConnection> sinkConnections = context.getSinkConnections();
Reporter reporter = ExtensionLoader.getExtensionLoader(Reporter.class).
loadExtension(null, "default");
loadExtension(null, properties.getReporter());
writers = sinkConnections.stream().
map(sink -> {
Writer<?> writer = ExtensionLoader.getExtensionLoader(Writer.class).
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ gradleWrapper=7.1.1
checkstylePlugin=8.44
# test dependencies version
jupiter=5.7.2
mockito=3.11.2
mockito=3.12.4
# dependencies version
## demo
h2=1.4.200
## common
jackson=2.12.4
jackson=2.12.5
slf4j=1.7.32
### transfer/jdbc
hikari=5.0.0
Expand Down
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
rootProject.name = 'porter'
include 'api'
include 'common'
include 'spi'
include 'transfer'
include 'core'
include 'transfer:jdbc'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public void doRead(Map<String, Column> columnMap) {
}
relation.getData().add(row);
if (batch % DEFAULT_BATCH_SIZE == 0) {
logger.log(Level.INFO, String.format("read %d rows from %s %s",
batch, srcConnection.getType(), srcConnection.getUrl()));
this.pushToChannel(new Result<>(seq++, relation));
relation = new Relation(meta);
}
Expand All @@ -70,7 +68,7 @@ public void doRead(Map<String, Column> columnMap) {
Instant end = Instant.now();
long seconds = Duration.between(start, end).toSeconds();
logger.log(Level.INFO, String.format(
"read completed. %s rows have been read, cost %s second(s)", batch, seconds));
"%s rows have been read, cost %s second(s)", batch, seconds));
try {
if (resultSet != null) {
resultSet.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void createTable(Result<?> data) {
List<Column> meta = ((Relation) data.getResult()).getMeta();
logger.log(Level.FINE, String.format("meta of table %s is: \n%s", tableIdentifier, Jsons.toJson(meta)));
String ddl = getCreateDDL(tableIdentifier, quote, meta);
logger.log(Level.INFO, String.format("create table %s: \n\n%s\n", tableIdentifier, ddl));
logger.log(Level.INFO, String.format("create table %s: \n%s", tableIdentifier, ddl));
try (Statement stmt = connection.createStatement()) {
stmt.executeUpdate(ddl);
} catch (SQLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ public void read() {
SrcConnection.Properties properties = srcConnection.getProperties();
Map<String, Column> tableMetaData = new LinkedHashMap<>();
if (properties.isTable() && properties.isCreate()) {
logger.log(Level.INFO, String.format("reading table metadata of %s %s...",
srcConnection.getType(), srcConnection.getUrl()));
tableMetaData = getTableMetaData();
}
initProperties(tableMetaData);
logger.log(Level.FINE, String.format("%s, reading table data from %s %s...",
properties.getSql(), srcConnection.getType(), srcConnection.getUrl()));
doRead(tableMetaData);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public <T> void report(T t) {
Result<?> result = (Result<?>) t;
logger.log(Level.INFO, String.format("wrote %sth batch", result.getSequenceNum()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
import de.xab.porter.api.annoation.Inject;
import de.xab.porter.api.dataconnection.DataConnection;
import de.xab.porter.api.dataconnection.SinkConnection;
import de.xab.porter.common.util.Loggers;
import de.xab.porter.transfer.channel.Channel;
import de.xab.porter.transfer.connector.Connector;
import de.xab.porter.transfer.exception.ConnectionException;

import java.util.logging.Level;
import java.util.logging.Logger;

import static de.xab.porter.common.enums.SequenceEnum.LAST_IS_EMPTY;
import static de.xab.porter.common.enums.SequenceEnum.isFirst;

Expand All @@ -21,7 +17,6 @@
public abstract class AbstractWriter<T> implements Writer<T> {
protected T connection;
private Connector<?> connector;
private final Logger logger = Loggers.getLogger(this.getClass());
private Channel channel;

@Override
Expand All @@ -34,18 +29,12 @@ public void write(Result<?> data) {

if (isFirst(data.getSequenceNum())) {
if (properties.isDrop()) {
logger.log(Level.FINE, String.format("dropping table %s %s...",
sinkConnection.getType(), sinkConnection.getUrl()));
dropTable();
}
if (properties.isCreate()) {
logger.log(Level.FINE, String.format("creating table %s %s...",
sinkConnection.getType(), sinkConnection.getUrl()));
createTable(data);
}
}
logger.log(Level.FINE, String.format("writing data to %s %s...",
sinkConnection.getType(), sinkConnection.getUrl()));
if (data.getSequenceNum() != LAST_IS_EMPTY.getSequenceNum()) {
doWrite(data);
}
Expand Down

0 comments on commit e26e476

Please sign in to comment.