Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug logs #92

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.uid2</groupId>
<artifactId>uid2-optout</artifactId>
<version>2.9.0-685b9893b7</version>
<version>2.9.6-SNAPSHOT</version>

<name>uid2-optout</name>
<url>https://github.com/IABTechLab/uid2-optout</url>
Expand Down
27 changes: 24 additions & 3 deletions src/main/java/com/uid2/optout/vertx/OptOutSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -404,11 +405,30 @@ private void deltaReplay(Promise<Void> promise, OptOutCollection store, List<Str
String filenames = String.join(",", fileList);

// sequentially send each entry
Future<Void> lastOp = Future.succeededFuture();
var ref = new Object() {
Future<Void> lastOp = Future.succeededFuture();
};

List<Future<Void>> sendOps = new ArrayList<Future<Void>>();

long periodicId = this.vertx.setPeriodic(1000, l -> {
int completeSendOps = 0;
for (Future<Void> sendOp : sendOps) {
if (sendOp.isComplete()) {
completeSendOps++;
}
}

this.logger.info("Completed " + completeSendOps + " send ops out of " + sendOps.size());
this.logger.info("LastOp is complete: " + ref.lastOp.isComplete());
});

for (int i = 0; i < store.size(); ++i) {
final OptOutEntry entry = store.get(i);
lastOp = lastOp.compose(ar -> {
ref.lastOp = ref.lastOp.compose(ar -> {
Future<Void> sendOp = this.remotePartner.send(entry);
sendOp.timeout(1, TimeUnit.MINUTES);
sendOps.add(sendOp);
return sendOp.onComplete(v -> {
if (v.succeeded()) {
recordEntryReplayStatus("success");
Expand All @@ -428,7 +448,8 @@ private void deltaReplay(Promise<Void> promise, OptOutCollection store, List<Str
});
}

lastOp.onComplete(ar -> {
ref.lastOp.onComplete(ar -> {
this.vertx.cancelTimer(periodicId);
if (ar.failed()) {
this.logger.error("deltaReplay failed sending delta " + filenames + " to remote: " + this.remotePartner.name(), ar.cause());
this.logger.error("deltaReplay has " + this.pendingFilesCount.get() + " pending file");
Expand Down