Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Brooks committed May 10, 2024
1 parent 2541ce9 commit 1768fe5
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.function.Supplier;

Expand Down Expand Up @@ -428,8 +430,10 @@ public void addUnresponsiveRule(TransportAddress transportAddress) {
);

transport().addSendBehavior(transportAddress, new StubbableTransport.SendRequestBehavior() {
private volatile boolean isClosed = false;
private final Set<Transport.Connection> toClose = ConcurrentHashMap.newKeySet();


@Override
public void sendRequest(
Transport.Connection connection,
Expand All @@ -438,6 +442,9 @@ public void sendRequest(
TransportRequest request,
TransportRequestOptions options
) {
if (isClosed) {
logger.error("ADDED REQUEST AFTER BEHAVIOR CLEARED");
}
// don't send anything, the receiving node is unresponsive
toClose.add(connection);
}
Expand All @@ -447,6 +454,7 @@ public void clearCallback() {
// close to simulate that tcp-ip eventually times out and closes connection (necessary to ensure transport eventually
// responds).
try {
isClosed = true;
IOUtils.close(toClose);
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down

0 comments on commit 1768fe5

Please sign in to comment.