diff --git a/src/main/java/com/teragrep/rlp_01/RelpClientPlainSocket.java b/src/main/java/com/teragrep/rlp_01/RelpClientPlainSocket.java index bceadbb..e736aee 100644 --- a/src/main/java/com/teragrep/rlp_01/RelpClientPlainSocket.java +++ b/src/main/java/com/teragrep/rlp_01/RelpClientPlainSocket.java @@ -130,7 +130,9 @@ void open (String hostname, int port) throws IOException, TimeoutException { @Override void write(ByteBuffer byteBuffer) throws IOException, TimeoutException { SelectionKey key = this.socketChannel.register(this.poll, SelectionKey.OP_WRITE); - LOGGER.trace("relpConnection.sendRelpRequestAsync> need to write <{}> ", byteBuffer.hasRemaining()); + if(LOGGER.isTraceEnabled()) { + LOGGER.trace("relpConnection.sendRelpRequestAsync> need to write <{}> ", byteBuffer.hasRemaining()); + } while (byteBuffer.hasRemaining()) { int nReady = poll.select(this.writeTimeout); @@ -147,7 +149,9 @@ void write(ByteBuffer byteBuffer) throws IOException, TimeoutException { } eventIter.remove(); } - LOGGER.trace("relpConnection.sendRelpRequestAsync> still need to write <{}>", byteBuffer.hasRemaining()); + if(LOGGER.isTraceEnabled()) { + LOGGER.trace("relpConnection.sendRelpRequestAsync> still need to write <{}>", byteBuffer.hasRemaining()); + } } key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE); } diff --git a/src/main/java/com/teragrep/rlp_01/RelpClientTlsSocket.java b/src/main/java/com/teragrep/rlp_01/RelpClientTlsSocket.java index 03c6d73..401cc0c 100644 --- a/src/main/java/com/teragrep/rlp_01/RelpClientTlsSocket.java +++ b/src/main/java/com/teragrep/rlp_01/RelpClientTlsSocket.java @@ -152,8 +152,9 @@ void open(String hostname, int port) throws IOException, TimeoutException { @Override void write(ByteBuffer byteBuffer) throws IOException, TimeoutException { SelectionKey key = this.socketChannel.register(this.selector, SelectionKey.OP_WRITE); - LOGGER.trace("relpConnection.sendRelpRequestAsync> need to write <{}>", byteBuffer.hasRemaining()); - + if(LOGGER.isTraceEnabled()) { + LOGGER.trace("relpConnection.sendRelpRequestAsync> need to write <{}>", byteBuffer.hasRemaining()); + } while (byteBuffer.hasRemaining()) { int nReady = selector.select(this.writeTimeout); if (nReady == 0) { @@ -176,7 +177,9 @@ void write(ByteBuffer byteBuffer) throws IOException, TimeoutException { } eventIter.remove(); } - LOGGER.trace("relpConnection.sendRelpRequestAsync> still need to write <{}>", byteBuffer.hasRemaining()); + if(LOGGER.isTraceEnabled()) { + LOGGER.trace("relpConnection.sendRelpRequestAsync> still need to write <{}>", byteBuffer.hasRemaining()); + } } } diff --git a/src/main/java/com/teragrep/rlp_01/RelpConnection.java b/src/main/java/com/teragrep/rlp_01/RelpConnection.java index d2784a6..7814d8d 100644 --- a/src/main/java/com/teragrep/rlp_01/RelpConnection.java +++ b/src/main/java/com/teragrep/rlp_01/RelpConnection.java @@ -227,7 +227,9 @@ public void commit(RelpBatch relpBatch) throws IOException, IllegalStateExceptio */ private void sendBatch(RelpBatch relpBatch) throws IOException, TimeoutException, IllegalStateException { - LOGGER.trace("relpConnection.sendBatch> entry with wq len <{}>", relpBatch.getWorkQueueLength()); + if(LOGGER.isTraceEnabled()) { + LOGGER.trace("relpConnection.sendBatch> entry with wq len <{}>", relpBatch.getWorkQueueLength()); + } // send a batch of requests.. RelpFrameTX relpRequest; @@ -272,7 +274,9 @@ private void readAcks(RelpBatch relpBatch) parser.parse(preAllocatedRXBuffer.get()); if (parser.isComplete()) { - LOGGER.trace("relpConnection.readAcks> read parser complete <{}>", parser.isComplete()); + if(LOGGER.isTraceEnabled()) { + LOGGER.trace("relpConnection.readAcks> read parser complete <{}>", parser.isComplete()); + } // one response read successfully int txnId = parser.getTxnId(); if (window.isPending(txnId)) { @@ -305,11 +309,15 @@ private void sendRelpRequestAsync(RelpFrameTX relpRequest) throws IOException, T LOGGER.trace("relpConnection.sendRelpRequestAsync> entry"); ByteBuffer byteBuffer; if (relpRequest.length() > this.txBufferSize) { - LOGGER.trace("relpConnection.sendRelpRequestAsync> allocate new txBuffer of size <{}>", relpRequest.length()); + if(LOGGER.isTraceEnabled()) { + LOGGER.trace("relpConnection.sendRelpRequestAsync> allocate new txBuffer of size <{}>", relpRequest.length()); + } byteBuffer = ByteBuffer.allocateDirect(relpRequest.length()); } else { - LOGGER.trace("relpConnection.sendRelpRequestAsync> using preAllocatedTXBuffer for size <{}>", relpRequest.length()); + if(LOGGER.isTraceEnabled()) { + LOGGER.trace("relpConnection.sendRelpRequestAsync> using preAllocatedTXBuffer for size <{}>", relpRequest.length()); + } byteBuffer = this.preAllocatedTXBuffer; } relpRequest.write(byteBuffer);