Skip to content

Commit

Permalink
Better logs
Browse files Browse the repository at this point in the history
  • Loading branch information
labianchin committed Oct 26, 2020
1 parent 1d24259 commit 1fc7071
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,18 @@ public class AvroWriter implements Runnable {

private static final Logger LOGGER = LoggerFactory.getLogger(AvroWriter.class);
private final DataFileWriter<GenericRecord> dataFileWriter;
private final JdbcAvroMetering metering;
private final BlockingQueue<ByteBuffer> queue;

public AvroWriter(
DataFileWriter<GenericRecord> dataFileWriter,
JdbcAvroMetering metering,
BlockingQueue<ByteBuffer> queue) {
this.dataFileWriter = dataFileWriter;
this.metering = metering;
this.queue = queue;
}

@Override
public void run() {
LOGGER.debug("AvroWriter started");
try {
while (true) {
final ByteBuffer datum = queue.take();
Expand All @@ -61,10 +59,9 @@ public void run() {
}
}
} catch (InterruptedException ex) {
System.out.println("CONSUMER INTERRUPTED");
LOGGER.warn("AvroWriter interrupted");
} catch (IOException e) {
e.printStackTrace();
LOGGER.error("Error on AvroWriter", e);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public Void getDestination() {
@SuppressWarnings("deprecation") // uses internal test functionality.
@Override
protected void prepareWrite(final WritableByteChannel channel) throws Exception {
LOGGER.info("jdbcavroio : Preparing write...");
LOGGER.debug("jdbcavroio : Preparing write...");
connection = jdbcAvroArgs.jdbcConnectionConfiguration().createConnection();
final Void destination = getDestination();
final Schema schema = dynamicDestinations.getSchema(destination);
Expand All @@ -177,7 +177,7 @@ protected void prepareWrite(final WritableByteChannel channel) throws Exception
dataFileWriter.setMeta("created_by", this.getClass().getCanonicalName());
this.countingOutputStream = new CountingOutputStream(Channels.newOutputStream(channel));
dataFileWriter.create(schema, this.countingOutputStream);
LOGGER.info("jdbcavroio : Write prepared");
LOGGER.debug("jdbcavroio : Write prepared");
}

private ResultSet executeQuery(final String query) throws Exception {
Expand Down Expand Up @@ -238,7 +238,7 @@ private void convertAllResultSet(ResultSet resultSet, JdbcAvroRecordConverter co

@Override
protected void finishWrite() throws Exception {
LOGGER.info("jdbcavroio : Closing connection, flushing writer...");
LOGGER.debug("jdbcavroio : Closing connection, flushing writer...");
if (connection != null) {
connection.close();
}
Expand Down

0 comments on commit 1fc7071

Please sign in to comment.