Skip to content

Commit

Permalink
remove commented-out LOGGER calls (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
eemhu authored Feb 27, 2024
1 parent 501dc35 commit 5563de7
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 58 deletions.
7 changes: 1 addition & 6 deletions src/main/java/com/teragrep/rlp_03/context/RelpReadImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ public void run() {
LOGGER.debug("resuming buffer <{}>, activeBuffers <{}>", activeBuffers.get(0), activeBuffers);
}
complete = innerLoop(relpFrame, true);
//LOGGER.info("complete <{}> after resume", complete);
}
//LOGGER.debug("activeBuffers.isEmpty() <{}>", activeBuffers.isEmpty());

while (activeBuffers.isEmpty() && !complete) {
//LOGGER.debug("while activeBuffers.isEmpty() <{}>", activeBuffers.isEmpty());
// fill buffers for read
long readBytes = readData();

Expand All @@ -97,7 +95,6 @@ public void run() {
}

if (relpFrame.endOfTransfer().isComplete()) {
//LOGGER.debug("frame complete");
LOGGER.trace("received relpFrame <[{}]>", relpFrame);

LOGGER.debug("unlocking at frame complete, activeBuffers <{}>", activeBuffers);
Expand Down Expand Up @@ -138,13 +135,11 @@ private boolean innerLoop(RelpFrameLeaseful relpFrame, boolean hasRef) {
break;
}
}
//LOGGER.debug("innerLoop rv <{}>", rv);
return rv;
}

private boolean readBytesToOperation(long readBytes) {
if (readBytes == 0) {
//LOGGER.debug("socket need to read more bytes");
// socket needs to read more
try {
connectionContext.interestOps().add(OP_READ);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public boolean attemptRelease() {
removeRef();
if (isRefCountZero()) {
buffer().clear();
// LOGGER.info("released bufferLease id <{}>, refs <{}>", bufferLease.id(), bufferLease.refs());
rv = true;
}
return rv;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public void offer(BufferLease bufferLease) {
}

private void internalOffer(BufferLease bufferLease) {
//LOGGER.info("internalOffer <{}>", queue.size());
if (!bufferLease.isStub()) {
queue.add(bufferLease);
}
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/com/teragrep/rlp_03/context/frame/RelpFrameImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

// TODO Design how to use Access properly if RelpFrames are also poolable
public class RelpFrameImpl implements RelpFrame {
//private static final Logger LOGGER = LoggerFactory.getLogger(RelpFrameImpl.class);

private final Fragment txn;
private final Fragment command;
private final Fragment payloadLength;
Expand All @@ -30,34 +28,24 @@ public RelpFrameImpl() {

public boolean submit(ByteBuffer input) {
boolean rv = false;
//LOGGER.info("submit for input <{}>", input);

while (input.hasRemaining() && !rv) {
//LOGGER.info("thisBuffer <{}>", input);

if (!txn.isComplete()) {
//LOGGER.info("accepting into TXN thisBuffer <{}>", input);
txn.accept(input);
} else if (!command.isComplete()) {
//LOGGER.info("accepting into COMMAND thisBuffer <{}>", input);
command.accept(input);
} else if (!payloadLength.isComplete()) {
//LOGGER.info("accepting into PAYLOAD LENGTH thisBuffer <{}>", input);

payloadLength.accept(input);

if (payloadLength.isComplete()) {
// PayloadFunction depends on payload length and needs to by dynamically created
int payloadSize = payloadLength.toInt();
//LOGGER.info("creating PayloadFunction with payloadSize <{}>", payloadSize);
payload = new FragmentImpl(new PayloadFunction(payloadSize));
}
} else if (!payload.isComplete()) {
//LOGGER.info("accepting into PAYLOAD thisBuffer <{}>", input);

payload.accept(input);
} else if (!endOfTransfer.isComplete()) {
//LOGGER.info("accepting into endOfTransfer");
endOfTransfer.accept(input);

if (endOfTransfer.isComplete()) {
Expand All @@ -67,10 +55,7 @@ public boolean submit(ByteBuffer input) {
} else {
throw new IllegalStateException("submit not allowed on a complete frame");
}

//LOGGER.info("after read input <{}>", input);
}
//LOGGER.info("returning rv <{}>", rv);
return rv;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
import java.util.function.BiFunction;

public class FragmentImpl implements Fragment {

//private static final Logger LOGGER = LoggerFactory.getLogger(FragmentImpl.class);

private final LinkedList<ByteBuffer> bufferSliceList;

// BiFunction is the parser function that takes: input, storageList, return value
Expand All @@ -26,15 +23,12 @@ public FragmentImpl(BiFunction<ByteBuffer, LinkedList<ByteBuffer>, Boolean> pars

@Override
public void accept(ByteBuffer input) {
// LOGGER.info("accept input<{}> with bufferSliceList.size() <{}>", input, bufferSliceList.size());

if (isComplete.get()) {
throw new IllegalStateException("Fragment is complete, can not accept more.");
}

if (parseRule.apply(input, bufferSliceList)) { // TODO change to buffers and scatter gather pattern?
isComplete.set(true);
//LOGGER.info("isComplete.get() <{}>", isComplete.get());
}
}

Expand All @@ -50,13 +44,11 @@ public boolean isComplete() {

@Override
public byte[] toBytes() {
//LOGGER.info("called toBytes");
if (!isComplete.get()) {
throw new IllegalStateException("Fragment incomplete!");
}

int totalBytes = 0;
// LOGGER.info("concatenating from bufferSliceList.size <{}>", bufferSliceList.size());
for (ByteBuffer slice : bufferSliceList) {
totalBytes = totalBytes + slice.remaining();
}
Expand All @@ -68,9 +60,8 @@ public byte[] toBytes() {
slice.asReadOnlyBuffer().get(bytes, copiedBytes, remainingBytes);
copiedBytes = copiedBytes + remainingBytes;
}
//LOGGER.info("BYTES! parseRule <{}> returning bytes <{}>", parseRule, new String(bytes, StandardCharsets.UTF_8));
return bytes;

return bytes;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@
import java.util.function.BiFunction;

public class EndOfTransferFunction implements BiFunction<ByteBuffer, LinkedList<ByteBuffer>, Boolean> {

//private static final Logger LOGGER = LoggerFactory.getLogger(EndOfTransferFunction.class);

@Override
public Boolean apply(ByteBuffer input, LinkedList<ByteBuffer> bufferSliceList) {
// LOGGER.info("apply with input <{}> bufferSliceList.size() <{}>", input, bufferSliceList.size());
ByteBuffer slice = input.slice();
int bytesRead = 0;
boolean rv = false;
if (input.hasRemaining()) {
byte b = input.get();
bytesRead++;
// LOGGER.info("read byte b <{}>", new String(new byte[]{b}, StandardCharsets.UTF_8));

if (b == '\n') {
// RelpFrame always ends with a newline byte.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import java.util.function.BiFunction;

public class PayloadFunction implements BiFunction<ByteBuffer, LinkedList<ByteBuffer>, Boolean> {

// private static final Logger LOGGER = LoggerFactory.getLogger(PayloadFunction.class);

final int payloadLength;

final AtomicInteger byteCount;
Expand All @@ -24,24 +21,19 @@ public PayloadFunction(int payloadLength) {
public Boolean apply(ByteBuffer input, LinkedList<ByteBuffer> bufferSliceList) {
ByteBuffer slice = input.slice();
if (byteCount.get() + ((ByteBuffer) slice).limit() <= payloadLength) {
// LOGGER.info("adding whole buffer byteCount.get() <{}> input.limit() <{}>", byteCount.get(), input.limit());
// whole buffer is part of this payload
byteCount.addAndGet(((ByteBuffer) slice).limit());
input.position(input.limit()); // consume all
// LOGGER.info("total byte count after adding whole buffer <{}>", byteCount.get());
}
else {
// LOGGER.info("adding partial buffer byteCount.get() <{}> input.limit() <{}>", byteCount.get(), input.limit());
int size = payloadLength - byteCount.get();
((ByteBuffer) slice).limit(size);
input.position(input.position() + size); // consume rest of the payload
byteCount.addAndGet(size);
// LOGGER.info("created bufferSlice <{}>", bufferSlice);
}

bufferSliceList.add(slice);

// LOGGER.info("return <{}> because byteCount.get() <{}> payloadLength <{}>", byteCount.get() == payloadLength, byteCount.get(), payloadLength);
return byteCount.get() == payloadLength;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import java.util.function.BiFunction;

public class PayloadLengthFunction implements BiFunction<ByteBuffer, LinkedList<ByteBuffer>, Boolean> {

//private static final Logger LOGGER = LoggerFactory.getLogger(PayloadLengthFunction.class);

private static final int maximumLengthNumbers = String.valueOf(Integer.MAX_VALUE).length() + 1; // space
public PayloadLengthFunction() {
}
Expand All @@ -25,7 +22,6 @@ public Boolean apply(ByteBuffer input, LinkedList<ByteBuffer> bufferSliceList) {
while (input.hasRemaining()) {
byte b = input.get();
bytesRead++;
//LOGGER.info("input <{}>, b <{}>, bufferSliceList <{}>", input, new String(new byte[]{b}, StandardCharsets.UTF_8), bufferSliceList);
checkOverSize(bytesRead, bufferSliceList);
if ( b == '\n') {
/*
Expand All @@ -51,8 +47,6 @@ else if (b == ' ') {
}

bufferSliceList.add(slice);

//LOGGER.info("returning <{}> with bufferSliceList <{}>", rv, bufferSliceList);
return rv;
}

Expand All @@ -65,7 +59,6 @@ private void checkOverSize(int bytesRead, LinkedList<ByteBuffer> bufferSliceList
currentLength = currentLength + bytesRead;
if (currentLength > maximumLengthNumbers) {
IllegalArgumentException illegalArgumentException = new IllegalArgumentException("payloadLength too long");
//LOGGER.info("payloadLength oversize <{}>", currentLength, illegalArgumentException);
throw illegalArgumentException;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import java.util.function.BiFunction;

public class TransactionFunction implements BiFunction<ByteBuffer, LinkedList<ByteBuffer>, Boolean> {

//private static final Logger LOGGER = LoggerFactory.getLogger(TransactionFunction.class);

private static final int maximumIdNumbers = String.valueOf(Integer.MAX_VALUE).length() + 1; // space
public TransactionFunction() {
}
Expand All @@ -27,7 +24,6 @@ public Boolean apply(ByteBuffer input, LinkedList<ByteBuffer> bufferSliceList) {
byte b = input.get();
bytesRead++;
checkOverSize(bytesRead, bufferSliceList);
//LOGGER.info("read byte b <{}>", new String(new byte[]{b}, StandardCharsets.UTF_8));
if (b == ' ') {
((ByteBuffer) slice).limit(bytesRead - 1);
rv = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public void testRelpFrameAssemblyMultipart() {
RelpFrameImpl relpFrame = new RelpFrameImpl();
for (int contentIter = 0; contentIter < contentBytes.length; contentIter++) {
// feed one at a time
// LOGGER.info("contentIter <{}>", contentIter);
ByteBuffer input = ByteBuffer.allocateDirect(1);
input.put(contentBytes[contentIter]);
input.flip();
Expand Down

0 comments on commit 5563de7

Please sign in to comment.